package com.charging.service.impl;

import com.charging.dao.PaymentRecordDao;
import com.charging.entity.PaymentRecord;
import com.charging.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;

@Service
public class PaymentServiceImpl implements PaymentService {

    @Autowired
    private PaymentRecordDao paymentRecordDao;

    @Override
    public PaymentRecord getLastRecharge(Long userId) {
        return paymentRecordDao.selectLastRecharge(userId);
    }

    @Override
    public Double getTotalRechargeAmount(Long userId) {
        return paymentRecordDao.sumRechargeAmount(userId);
    }

    @Override
    public void savePaymentRecord(PaymentRecord record) {
        record.setCreateTime(new Date());
        record.setUpdateTime(new Date());
        paymentRecordDao.insert(record);
    }

    @Override
    public List<PaymentRecord> getRecentRecharges(Long userId, int limit) {
        return Collections.emptyList();
    }
}
